<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:zanata="http://java.sun.com/jsf/composite/zanata">

<ui:composition template="../WEB-INF/template/template.xhtml">
  <f:metadata>
    <f:viewParam name="username" value="#{userAction.username}" />
    <f:event type="preRenderView" listener="#{userAction.loadUser()}"/>
    <f:event type="preRenderView" listener="#{identity.checkRole('admin')}"/>
  </f:metadata>

  <ui:define name="head">
    <style type="text/css">
      .checkbox label {
        padding: 0 0.40625em;
      }
    </style>
  </ui:define>

  <ui:define
    name="page_title">#{userAction.username} - #{msgs['jsf.AccountDetails']}</ui:define>
  <ui:define name="center_content">
    <div class="g--centered">
      <div class="g__item w--3-4-m w--5-8-l w--1-3 l--push-bottom-1">
        <p class="txt--meta l--push-all-0">
          <a href="/admin/home">
            #{msgs['jsf.Administration']}
          </a>
          <i class="i i--arrow-right"></i>
          <h:link outcome="/admin/usermanager.xhtml">
            #{msgs['jsf.ManageUsers']}
          </h:link>
        </p>

        <h1 class="l--push-all-0">#{msgs['jsf.AccountDetails']}</h1>

        <h:form id="userdetailForm"
          rendered="#{identityManager.userExists(userAction.username)}">

          <div class="form__item l--push-top-1">
            <h:outputLabel for="username">#{msgs['jsf.Username']}</h:outputLabel>
            <input id="username" type="text" disabled="disabled"
              value="#{userAction.username}"/>
          </div>

          <div class="form__item l--push-top-1">
            <h:outputLabel for="name">#{msgs['jsf.FullName']}</h:outputLabel>
            <h:inputText id="name" type="text" value="#{userAction.name}" maxlength="80"
              zanata:placeholder="#{userAction.originalName}"/>
          </div>

          <div class="form__item l--push-top-1">
            <h:outputLabel for="email">#{msgs['jsf.Email']}</h:outputLabel>
            <input id="email" type="text" disabled="disabled"
              value="#{userAction.getEmail(userAction.username)}"/>
          </div>

          <h:panelGroup layout="block"  styleClass="form__item l--push-top-1"
            rendered="#{applicationConfiguration.internalAuth}">
            <h:outputLabel for="password">#{msgs['jsf.password.change']}</h:outputLabel>
            <zanata:decorate id="password"
              componentId="passwordField">
              <div class="form__password js-form-password-parent">
                <h:inputSecret id="password"
                  styleClass="js-form-password-input form__input"
                  value="#{userAction.password}">
                </h:inputSecret>
                <a href="#" class="form__toggle js-form-password-toggle">Show</a>
              </div>
            </zanata:decorate>
          </h:panelGroup>

          <h:panelGroup layout="block"  styleClass="form__item l--push-top-1"
            rendered="#{applicationConfiguration.internalAuth}">
            <h:outputLabel for="confirm">#{msgs['jsf.ConfirmPassword']}</h:outputLabel>
            <zanata:decorate id="passwordConfirm"
              componentId="passwordConfirmField">
              <div class="form__password js-form-password-parent">
                <h:inputSecret id="confirm"
                  styleClass="js-form-password-input form__input"
                  value="#{userAction.confirm}">
                </h:inputSecret>
                <a href="#" class="form__toggle js-form-password-toggle">Show</a>
              </div>
            </zanata:decorate>
          </h:panelGroup>


          <div class="form__item l--push-top-1">
            <h:outputLabel>#{msgs['jsf.MemberOf']}</h:outputLabel>
            <zanata:decorate id="roles" componentId="rolesField">
              <h:selectManyCheckbox id="roles" value="#{userAction.roles}"
                layout="pageDirection" styleClass="checkbox">
                <f:selectItems value="#{identityManager.listGrantableRoles()}" var="role"
                  itemLabel="#{role}"/>
              </h:selectManyCheckbox>
            </zanata:decorate>
          </div>

          <div class="form__item l--push-top-1 checkbox">
            <h:outputLabel for="enabled">#{msgs['jsf.AccountEnabled']}</h:outputLabel>
            <h:selectBooleanCheckbox id="enabled" value="#{userAction.enabled}"/>
          </div>


          <h:commandButton id="userdetailSave" value="#{msgs['jsf.Save']}"
            action="#{userAction.save}" styleClass="button--primary"/>

          <h:commandLink id="userdetailCancel"
            value="#{msgs['jsf.Cancel']}" action="#{userAction.cancel}"
            styleClass="button button--link l--push-left-half"/>

        </h:form>

      </div>
    </div>
  </ui:define>

</ui:composition>
</html>
